WGCNA.HubGene <- function(Title,cor,con,moduleName,phenoName){
  ## 联通性计算
  # (1) Intramodular connectivity
  connet=abs(cor(datExpr,use="p"))^6
  Alldegrees1=intramodularConnectivity(connet, moduleColors)
  ###(3) Generalizing intramodular connectivity for all genes on the array
  datKME=signedKME(datExpr, MEs_col, outputColumnName="MM.")
  write.table(datKME, paste(Title,"Conectivity_of_each_modular.xls",sep = "."),
              sep = "\t",
              row.names = T,
              quote = F)
  # Display the first few rows of the data frame
  ##Finding genes with high gene significance and high intramodular connectivity in interesting modules
  PheName <- as.data.frame(design[,grep(phenoName,colnames(design))])
  names(PheName) = phenoName
  GS1 = as.numeric(cor(PheName,datExpr, use = "p"))
  # abs(GS1)模块和基因的关联性
  # abs(datKME$MM.green) 基因的连通性
  num <- grep(moduleName,colnames(datKME))
  FilterGenes= abs(GS1)> cor & abs(datKME[,num])>con
  
  hubGenes_raw = data.frame(ID = rownames(datKME),
                            TORF = FilterGenes)
  hubGenes = filter(hubGenes_raw, TORF == "TRUE")
  table(hubGenes)
  
  write.table(hubGenes,file = paste(Title,moduleName,phenoName,"hubGene.xls",
                                    sep = "_"),
              sep = "\t",
              row.names = F,
              quote = F)
}







